<?php
namespace App\Http\Controllers;

use DB;
use Cache;
use App\Collect;
use App\User;
//use Carbon\Carbon;
use Predis;

class IndexController extends BaseController
{
	/**
	 * 首页
	 */
	public function index()
	{
        /*列表数据*/
		$data = DB::table('house_info')->orderBy('id', 'desc')->paginate(50);

        /*我的收藏部分*/
        $collect_title_id = $this->mycollect(8);
        $collect = [];

        if( !empty($collect_title_id) )
        {
            $collect = DB::table('house_info')->whereIn('title_id', $collect_title_id)->get();
        }

		return view('index/index', compact('data', 'collect'));
	}

    public function image($tid)
    {
        $image = DB::table('imgs')->where('title_id',  $tid)->select('img_url')->lists('img_url');
        return response()->json($image);
    }

    public function square()
    {
        $user = DB::table('user')->select('id', 'username')->paginate(10);

        return View('index.square', compact('user'));
    }
}
